home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.pro;
-
- import java.io.EOFException;
- import java.util.Vector;
- import symantec.itools.db.net.BinaryInputStream;
- import symantec.itools.db.net.BinaryOutputStream;
- import symantec.itools.db.net.NetData;
- import symantec.itools.db.net.NetRecord;
- import symantec.itools.db.net.Param;
- import symantec.itools.db.net.RemoteObject;
- import symjava.sql.SQLException;
-
- class RelViewPos {
- Vector _relInfo;
- RelViewInfo _curInfo;
- int _offset;
- MultiView _mv;
- RemoteObject _mvRemObj;
-
- RelViewPos(MultiView mv) {
- this._mv = mv;
- this._relInfo = new Vector();
- this._curInfo = null;
- this._offset = 0;
- }
-
- MultiView getMultiView() {
- return this._mv;
- }
-
- RemoteObject getMVRemObj() {
- return this._mvRemObj;
- }
-
- RelViewPos cloneAtCurrentPos() {
- RelViewPos pos = new RelViewPos(this.getMultiView());
-
- for(int i = this._offset; i > 0; --i) {
- pos.addParentInfo((RelViewInfo)this._relInfo.elementAt(i - 1));
- }
-
- pos.setMVRemObj(this._mvRemObj);
- return pos;
- }
-
- RelViewPos next() {
- if (!this.over()) {
- this._curInfo = (RelViewInfo)this._relInfo.elementAt(this._offset++);
- } else {
- this._curInfo = null;
- }
-
- return this;
- }
-
- RelViewPos reset() {
- this._offset = 0;
- this._curInfo = null;
- if (this._relInfo.size() > 0) {
- this._curInfo = (RelViewInfo)this._relInfo.elementAt(this._offset++);
- }
-
- return this;
- }
-
- boolean over() {
- if (this._curInfo == null) {
- return true;
- } else {
- return this._curInfo.getRecNum() == 0;
- }
- }
-
- int getRowsToRequest() {
- if (this._relInfo.size() > 0) {
- RelViewInfo info = (RelViewInfo)this._relInfo.elementAt(this._relInfo.size() - 1);
- return info.getNumRowsToRequest();
- } else {
- return 1;
- }
- }
-
- int getID() {
- return this._curInfo.getID();
- }
-
- int getRecNum() {
- return this._curInfo.getRecNum();
- }
-
- int getProxyID() {
- return this._curInfo.getProxyID();
- }
-
- void addParentInfo(RelViewInfo info) {
- this._relInfo.insertElementAt(info, 0);
- }
-
- void setMVRemObj(RemoteObject obj) {
- this._mvRemObj = obj;
- }
-
- private void addPosInfoToParams(Vector params) {
- params.addElement(new Param(0, this._relInfo.size()));
-
- for(int i = 0; i < this._relInfo.size(); ++i) {
- RelViewInfo info = (RelViewInfo)this._relInfo.elementAt(i);
- params.addElement(new Param(0, info.getProxyID(), true));
- params.addElement(new Param(0, info.getRecNum()));
- }
-
- }
-
- int getRemoteStreamID(int recID, int colIndex) throws SQLException {
- Vector params = new Vector();
- params.addElement(new Param(0, recID));
- params.addElement(new Param(0, colIndex));
- this.addPosInfoToParams(params);
- Vector results = this._mvRemObj.invokeMethod(9, params);
- NetData d = (NetData)results.elementAt(0);
-
- try {
- return d.getInt();
- } catch (EOFException e) {
- throw new SQLException(((Throwable)e).getMessage());
- }
- }
-
- BinaryInputStream getRemoteInputStream(int recID, int colIndex) throws SQLException {
- int id = this.getRemoteStreamID(recID, colIndex);
- return new BinaryInputStream(id, this._mvRemObj.getSession());
- }
-
- BinaryOutputStream getRemoteOutputStream(int recID, int colIndex) throws SQLException {
- int id = this.getRemoteStreamID(recID, colIndex);
- return new BinaryOutputStream(id, this._mvRemObj.getSession());
- }
-
- NetRecord getNewServerRecord() throws SQLException {
- Vector params = new Vector();
- this.addPosInfoToParams(params);
- Vector results = this._mvRemObj.invokeMethod(7, params);
- return (NetRecord)results.elementAt(0);
- }
-
- void deleteServerRecord(NetRecord rec, int recnum) throws SQLException {
- Vector params = new Vector();
- params.addElement(new Param(0, recnum));
- this.addPosInfoToParams(params);
- this._mvRemObj.invokeMethod(6, params);
- rec.setState((byte)103);
- }
-
- void undoServerRecord(NetRecord rec, int recnum) throws SQLException {
- Vector params = new Vector();
- params.addElement(new Param(0, recnum));
- this.addPosInfoToParams(params);
- Vector results = this._mvRemObj.invokeMethod(5, params);
- NetRecord newrec = (NetRecord)results.elementAt(0);
- rec.copy(newrec);
- }
-
- void notifyServerOfDataChange(NetRecord rec) throws SQLException {
- Vector params = new Vector();
- params.addElement(rec);
- this.addPosInfoToParams(params);
- this._mvRemObj.invokeMethod(1, params);
- }
-
- Vector fetchRecords(int startRec, int numRecs) throws SQLException {
- Vector params = new Vector();
- params.addElement(new Param(0, startRec));
- params.addElement(new Param(0, numRecs));
- this.addPosInfoToParams(params);
- return this._mvRemObj.invokeMethod(0, params);
- }
- }
-